﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyHealthOnline.Business;
using MyHealthOnline.Dal.Generated.CollectionClasses;

namespace MyHealthOnline.Specialist
{
    public partial class OpenConsultations : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ucConsultations.SetGrid(ConsultsDataSource);
            }
        }

        public ConsultCollection Consults
        {
            get
            {
                return ViewState["Consults"] as ConsultCollection;
            }
            set
            {
                ViewState["Consults"] = value;
            }
        }

        private ConsultCollection consultsDataSource = null;
        private ConsultCollection ConsultsDataSource
        {
            get
            {
                return ConsultBusiness.GetOpenedConsults();
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            int nr = 0;
            var patientList = ConsultBusiness.FilterConsults( ConsultsDataSource,txtSearchPatient.Text);

            ucConsultations.SetGrid(patientList);
        }
    }
}